package cards.controller;

import cards.entity.User;
import cards.util.HostHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.servlet.View;
import org.springframework.web.servlet.view.RedirectView;

import javax.servlet.http.HttpServletRequest;

/**
 * 登录接口
 * 
 * @author xiezhiping
 *
 */
@Controller
public class LoginController {
	@Autowired
	private HostHolder hostHolder;

	@RequestMapping(path = "/login", method = RequestMethod.GET)
	public String login() {
		return "login";
	}

	@RequestMapping(path = "/transmit", method = RequestMethod.GET)
	public View transmit(HttpServletRequest request)
	{
		User user=hostHolder.getUser();
		String contextPath = request.getContextPath();
		if (user.getPermission() == 0) return new RedirectView(contextPath + "/user/unattended");
		else return new RedirectView(contextPath + "/admin/unattended");
	}
}
